package com.example.booksdeal.basic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.example.booksdeal.BmobDBO.User;
import com.example.booksdeal.R;
//import com.hyphenate.EMCallBack;
//import com.hyphenate.chat.EMClient;

public class SettingActivity extends AppCompatActivity {

    private LinearLayout changpwd,aboutus,version;
    private Button logout;
    private OnClick myOnClick;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        myOnClick = new OnClick();
        initView();
    }

    public void initView() {
        changpwd = findViewById(R.id.changepwd);
        aboutus = findViewById(R.id.aboutus);
        version = findViewById(R.id.version);
        logout = findViewById(R.id.logout);
        changpwd.setOnClickListener(myOnClick);
        aboutus.setOnClickListener(myOnClick);
        version.setOnClickListener(myOnClick);
        logout.setOnClickListener(myOnClick);
    }

    public class OnClick implements View.OnClickListener {

        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.changepwd:
                    break;
                case R.id.aboutus:
                    break;
                case R.id.version:
                    break;
                case R.id.logout:
                    getLoginExit();
                    break;
            }
        }
    }

    /**
     * 退出登录
     */
    private void getLoginExit(){
//        EMClient.getInstance().logout(true, new EMCallBack() {
//            @Override
//            public void onSuccess() {
                Intent intent = new Intent(SettingActivity.this,LoginActivity.class);
                // 注销功能
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                User.logOut();
                // TODO Auto-generated method stub
            }

//            @Override
//            public void onProgress(int progress, String status) {
//                // TODO Auto-generated method stub
//            }
//
//            @Override
//            public void onError(int code, String message) {
//                // TODO Auto-generated method stub
//            }
//        });
//    }
}
